﻿namespace @(Model.Namespace).WebApi.Controllers
{
    /// <summary>
    /// @(Model.CnName)相关api
    ///</summary>
    public class @(Model.Name)Controller : BaseApiController
    {
        /// <summary>
        /// 属性注入应用层
        /// </summary>
        public I@(Model.Name)Application @(Model.Name)Application { get; set; }

        /// <summary>
        /// 获取@(Model.CnName)分页结果
        ///</summary>
        [HttpPost]
        public async Task<PageResult<Get@(Model.Name)PageResultOutput>> GetPageResultAsync(Get@(Model.Name)PageResultInput input)
        {
            return await @(Model.Name)Application.GetPageResultAsync(input);
        }

        /// <summary>
        /// 获取@(Model.CnName)分页列表
        ///</summary>
        [HttpPost]
        public async Task<List<Get@(Model.Name)PageListOutput>> GetPageListAsync(Get@(Model.Name)PageListInput input)
        {
            return await @(Model.Name)Application.GetPageListAsync(input);
        }

        /// <summary>
        /// 获取@(Model.CnName)
        /// </summary>
        [HttpGet("{id}")]
        @if (Model.IsGuidKey){
<text>          public async Task<Get@(Model.Name)Output> GetAsync([FromRoute] string id)
</text>}
        else{
<text>          public async Task<Get@(Model.Name)Output> GetAsync([FromRoute] int id)
</text>}
        {
        @if (Model.IsGuidKey){<text>
            BaseGuidEntity input = new(id);
</text>}
        else{<text>
            BaseKeyEntity input = new(id);
</text>}
            return await @(Model.Name)Application.GetAsync(input);
        }

        /// <summary>
        /// 获取全部@(Model.CnName)
        /// </summary>
        [HttpGet]
        public async Task<List<Get@(Model.Name)ItemOutput>> GetAllListAsync()
        {
            return await @(Model.Name)Application.GetAllListAsync();
        }

        /// <summary>
        /// 修改@(Model.CnName)
        /// </summary>
        [HttpPost]
        public async Task UpdateAsync(Update@(Model.Name)Input input)
        {
            await @(Model.Name)Application.UpdateAsync(input);
        }

        /// <summary>
        /// 新增@(Model.CnName)
        /// </summary>
        [HttpPost]
        public async Task AddAsync(Add@(Model.Name)Input input)
        {
            await @(Model.Name)Application.AddAsync(input);
        }

        /// <summary>
        /// 删除@(Model.CnName)
        /// </summary>
        [HttpPost]
        @if (Model.IsGuidKey)
    {<text>
        public async Task DeleteAsync(BaseGuidListInput input)
</text>}
            else
            { <text>
        public async Task DeleteAsync(BaseIdListInput input)
</text>}
        {
            await @(Model.Name)Application.DeleteAsync(input);
        }
    }
}